// Copyright (c) 2007 Alistair Jones
// This program is made available under the terms of the MIT License.
package org.hypirinha.html.codegen;

import java.io.PrintStream;
import java.util.List;
import java.util.ArrayList;

public class ConcreteMethod implements Member {
    private String methodName;
    private String returnType;
    private List<String> modifiers = new ArrayList<String>();
    private String parameters;
    private String methodBody;


    public ConcreteMethod(String methodName, String returnType, String parameters, String methodBody) {
        this.methodName = methodName;
        this.returnType = returnType;
        this.parameters = parameters;
        this.methodBody = methodBody;
    }

    public void printTo(PrintStream printStream) {
        printStream.println();
        printStream.println("    public " + modifiers() + returnType + " " + methodName + "(" + parameters + ") {");
        printStream.println("        " + methodBody);
        printStream.println("    }");
    }

    private String modifiers() {
        String output = "";
        for (String modifier : modifiers) {
            output += modifier + " ";
        }
        return output;
    }

    public String getMethodName() {
        return methodName;
    }

    public String getReturnType() {
        return returnType;
    }

    public List<String> getModifiers() {
        return modifiers;
    }

    public String getMethodBody() {
        return methodBody;
    }
}
